package com.smartguard.service;

import java.util.ArrayList;
import java.util.List;

import com.smartguard.bean.Video;

public class VideoService extends BaseService{
	

	public boolean insertVideo(Video video){
		if(video == null) return false;
		else return this.getBaseDAO().insert(video);
	}
	public Video findOneVideo(Video video){
		if(video == null) return null;
		else return this.getBaseDAO().findOne(video);
	}
	
	public List<Video> findVideosByUsername(String username){
		ArrayList<Video> result = new ArrayList<Video>();
		if(username != null && !username.equals("")){
			Video ref = new Video();
			ref.setUsername(username);
			result.addAll(this.getBaseDAO().find(ref, -1));
		}
		return result;
	}
	
	public int deleteVideo(Video video) {
		return this.getBaseDAO().delete(video);
	}
	
	public static void main(String[] args) {
		VideoService videoService = new VideoService();
		List<Video> videoList = videoService.findVideosByUsername("username");
		for (Video video : videoList) {
			videoService.deleteVideo(video);
		}
		
	}

}
